package com.zsk.shop.enums;

import java.math.BigDecimal;

/**
 * 推荐下级奖励
 *
 * @author ljh
 * @create 2022/3/1 10:17
 */
public enum EnumRatioWithLv {

    GENERAL(1, BigDecimal.ZERO, new BigDecimal("0.1"), new BigDecimal("0.9")),
    YELLOW(2, new BigDecimal("0.05"), new BigDecimal("0.2"), new BigDecimal("0.8")),
    BLUE(3, new BigDecimal("0.1"), new BigDecimal("0.3"), new BigDecimal("0.7")),
    BLACK(4, new BigDecimal("0.15"), new BigDecimal("0.4"), new BigDecimal("0.6")),
    TOP(5, new BigDecimal("0.2"), new BigDecimal("0.5"), new BigDecimal("0.5")),
    ;

    Integer lv;
    BigDecimal ratio;
    BigDecimal moneyRatio;
    BigDecimal pointRatio;

    public BigDecimal getRatio() {
        return ratio;
    }

    public void setRatio(BigDecimal ratio) {
        this.ratio = ratio;
    }

    public Integer getLv() {
        return lv;
    }

    public void setLv(Integer lv) {
        this.lv = lv;
    }

    public BigDecimal getMoneyRatio() {
        return moneyRatio;
    }

    public void setMoneyRatio(BigDecimal moneyRatio) {
        this.moneyRatio = moneyRatio;
    }

    public BigDecimal getPointRatio() {
        return pointRatio;
    }

    public void setPointRatio(BigDecimal pointRatio) {
        this.pointRatio = pointRatio;
    }

    /**
     * @param lv
     * @param ratio      推荐奖励比例
     * @param moneyRatio 冻结转金额比例
     */
    EnumRatioWithLv(Integer lv, BigDecimal ratio, BigDecimal moneyRatio, BigDecimal pointRatio) {
        this.lv = lv;
        this.ratio = ratio;
        this.moneyRatio = moneyRatio;
        this.pointRatio = pointRatio;
    }

    public static BigDecimal getRecommendRatioByLv(Integer lv) {
        EnumRatioWithLv[] enums = EnumRatioWithLv.values();
        for (int i = 0; i < enums.length; i++) {
            if (enums[i].getLv().equals(lv)) {
                return enums[i].getRatio();
            }
        }
        return BigDecimal.ZERO;
    }

    public static BigDecimal getThawAccountRatioByLv(Integer lv) {
        EnumRatioWithLv[] enums = EnumRatioWithLv.values();
        for (int i = 0; i < enums.length; i++) {
            if (enums[i].getLv().equals(lv)) {
                return enums[i].getMoneyRatio();
            }
        }
        return BigDecimal.ZERO;
    }

    public static BigDecimal getThawPointRatioByLv(Integer lv) {
        EnumRatioWithLv[] enums = EnumRatioWithLv.values();
        for (int i = 0; i < enums.length; i++) {
            if (enums[i].getLv().equals(lv)) {
                return enums[i].getPointRatio();
            }
        }
        return BigDecimal.ZERO;
    }

}
